import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/src/widgets/bottom_sheet/filter_bottom_sheet.dart';

// import 'package:collection/collection.dart';
mixin FilterLeaveMixin<T> on BaseProvider<T> {
  List<String> currentSelectFilterList = [];

  int get filterListLength => currentSelectFilterList.length;

  void unFocus();

  void onRequestRefresh();

  void onShowFilter() {
    unFocus();
    obtainContext.call((context) async {
      final result = await showFilterLeaveBottomSheet(
        context,
        selectFilter: currentSelectFilterList,
      );
      if (result != null) {
        currentSelectFilterList = result;
        onRequestRefresh();
        update();
      }
    });
  }

  void onRemoveFilter(String value) {
    currentSelectFilterList.remove(value);
    onRequestRefresh();
    update();
  }
}
